﻿using System.Collections.Generic;
using OverStore.Runtime.OverStoreContext;
using OverStore.Runtime.PersistenceServiceProvider;
using OverStore.Runtime.ObjectRepository;

namespace OverStore.Configuration.PersistenceServiceProvider
{
    
    /// <summary>
    /// Allows to create new instances of <see cref="IPersistenceServiceProvider"/> type.
    /// For more information see <see cref="T:OverStore.Runtime.PersistenceServiceProvider.IPersistenceServiceProvider"/>.
    /// <seealso cref="T:OverStore.Runtime.PersistenceServiceProvider.IPersistenceServiceProvider."/>
    /// </summary>
    public interface IPersistenceServiceProviderConfiguration
    {
        /// <summary>
        /// 	<para>
        /// Implement method by performing following steps:
        /// </para>
        /// 	<list class="number">
        /// 		<listItem>
        /// Creates new instance of <see cref="IPersistenceServiceProvider"/> type. OverrideDbType implements <see cref="IPersistenceServiceProvider"/> should be
        /// specified for current configuration.
        /// </listItem>
        /// 		<listItem>
        /// Set property <see cref="P:OverStore.Runtime.OverStoreContext.OverStoreContextImplementation.PersistenceServiceProvider"/> of instance passed as
        /// <paramref name="context"/> argument with newly created <see cref="T:OverStore.Runtime.PersistenceServiceProvider.IPeristenceServiceProvider"/> instance.
        /// </listItem>
        /// 		<listItem>
        /// Create collections of  <see cref="T:OverStore.Runtime.Repository.IRepositoryBase"/> and
        /// <see cref="T:OverStore.Runtime.ObjectReader.ObjectReaderBase"/> using corresponding arguments <paramref name="repositories"/> and
        /// <paramref name="objectReaders"/>. Use <paramref name="context"/> result as argument for Create methods of corresponding configurations.
        /// </listItem>
        /// 		<listItem>
        /// Initialize newly created instance of <see cref="IPersistenceServiceProvider"/>
        /// with created collections.
        /// </listItem>
        /// 	</list>
        /// </summary>
        /// <param name="context">The context provides access to set of services.</param>
        /// <param name="repositories">The collection of object repository configurations.</param>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="context"/> is null reference.</exception>
        /// <exception cref="T:System.ArgumentNullException"><paramref name="repositories"/> is null reference.</exception>
        void SetupContext(OverStoreContextImplementation context, IEnumerable<IComponentConfiguration<IRepositoryBase>> repositories);
    }
}
